package ru.spb.osll.myfit.server.chart;

import ru.spb.osll.myfit.common.chart.ChartCurve;
import ru.spb.osll.myfit.common.chart.ChartCurveInfo;
import ru.spb.osll.myfit.common.chart.ChartInfo;

/**
 * User: Artem Bukhonov
 * Date: 29.03.12
 * Time: 19:29
 */
public class ChartUtils {
  public static void copyRenderData2ChartInfo(ChartRenderData data, ChartInfo info) {
    info.setHorizontalLabel(data.getHorizontalLabel());
    info.setVerticalLabel(data.getVerticalLabel());
    info.setName(data.getName());
    info.setTitle(data.getTitle());
    info.setWidth(data.getWidth());
    info.setHeight(data.getHeight());

    for (int i = 0; i < data.getCurves().size(); ++i) {
      ChartCurve chartCurve = data.getCurves().get(i);
      ChartCurveInfo curveInfo = new ChartCurveInfo(chartCurve.getName());

      curveInfo.setColorRGB(chartCurve.getColor());
      info.getCurves().add(curveInfo);
    }
  }

  public static void copyChartInfo2RenderData(ChartInfo info, ChartRenderData data) {
    data.setHorizontalLabel(info.getHorizontalLabel());
    data.setVerticalLabel(info.getVerticalLabel());
    data.setName(info.getName());
    data.setTitle(info.getTitle());
    data.setWidth(info.getWidth());
    data.setHeight(info.getHeight());
    for (int i = 0; i < data.getCurves().size(); ++i) {
      ChartCurveInfo chartCurveInfo = info.getCurves().get(i);
      ChartCurve chartCurve = data.getCurves().get(i);
      chartCurve.setName(chartCurveInfo.getName());
      chartCurve.setColorRGB(chartCurveInfo.getColorRGB());
    }
  }
}
